function EnableEmail(e)
{
	jQuery("#preffered_time").attr('disabled', true);
	jQuery('#emailme .formText').attr('enable',true);
	jQuery('#callme .formText').attr('disabled', true);		
	jQuery('#preferredtime .formText').attr('disabled', true);
	jQuery('#emailme :input').removeAttr('disabled');
	jQuery('#callme .formText').val("");
	jQuery('#preferredtime .formText').val("");		
	
}

function EnableContact(e)
{
	jQuery('#email').val(jQuery('#email').attr('inittext'));
	jQuery('#emailme .formText').attr('disabled',true);
	jQuery('#callme .formText').attr('enable', true);
	//jQuery('#preferredtime .formText').attr('enable', true);
	jQuery('#callme :input').removeAttr('disabled');
	jQuery('#preferredtime :input').removeAttr('disabled');
}
function clickOnField(field){
    var initText=field.getAttribute('inittext');	
    if(field.value==initText){
        field.value='';
    }
}
function blurOnField(field){
    var initText=field.getAttribute('inittext');
    if(field.value==''){
        field.value=initText;
    }	
}


function is_valid_email (email)
{	
	var emailPattern = /^([a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*@([a-z0-9-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z0-9-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*\.(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]){2,})$/i;
    return emailPattern.test(email);
}

function ToCellValidate(objMobileNo)
{ 
	var phone_number = objMobileNo.value;
		if(phone_number == "") return false;
	if(phone_number.search(/^((\+\d{1,3}(-| )?\(?\d\)?(-| )?\d{1,5})|(\(?\d{2,6}\)?))(-| )?(\d{3,4})(-| )?(\d{4})(( x| ext)\d{1,5}){0,1}$/) != -1){
		return true;
	}	
	objMobileNo.focus();
	objMobileNo.value="";

	alert('Please enter valid phone number');
	return false;
}

function fromsubmite(){	
	
	if(jQuery("input[name='contact_method']:checked").val() == 'email'){
		var emailadd=jQuery('#email').val();
		var inittext=jQuery('#email').attr('inittext'); 
		if(emailadd == "") return false;
		if(emailadd==inittext){
		   jQuery('#email').val("");
		   //alert(inittext);
		  return;
		}else{
			if(!is_valid_email(emailadd)){
				alert("Please enter a valid email address. For example johndoe@domain.com.");
			return;
			}
		}
	}
	if(jQuery("input[name='contact_method']:checked").val() == 'contact'){
		if(jQuery("input[name='phoneNumber']").val() == "") return false;
	}
	document.contactus.submit();
}
function strip_tags(html){

		//PROCESS STRING
		if(arguments.length < 3) {
			html=html.replace(/<\/?(?!\!)[^>]*>/gi, '');
		} else {
			var allowed = arguments[1];
			var specified = eval("["+arguments[2]+"]");
			if(allowed){
				var regex='</?(?!(' + specified.join('|') + '))\b[^>]*>';
				html=html.replace(new RegExp(regex, 'gi'), '');
			} else{
				var regex='</?(' + specified.join('|') + ')\b[^>]*>';
				html=html.replace(new RegExp(regex, 'gi'), '');
			}
		}

		//CHANGE NAME TO CLEAN JUST BECAUSE
		var clean_string = html;

		//RETURN THE CLEAN STRING
		return clean_string;
	}
jQuery(document).ready(function() {
 EnableEmail(); 
});
 